# date:20210221
from typing import List
import collections

# 运行时长：40%  内存：23%
class Solution:
    def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
        left, right = 0, len(matrix[0])-1
        flag = True
        for row in range(len(matrix)-1):
            if matrix[row][left:right] != matrix[row+1][left+1:right+1]:
                flag = False
                break
        return flag




model = Solution()

matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
print(model.isToeplitzMatrix(matrix))

matrix = [[1,2],[2,2]]
print(model.isToeplitzMatrix(matrix))